create or replace function fun_gy_gettoken(prm_source in out Varchar2,prm_separator in Varchar2) return varchar2 is
  Result varchar2(6000);
  n_p        Number(3);
  n_i        Number(3);
begin
  If prm_source Is Null Then
         prm_source := '';
         Result := '';
         return(Result);
   End If;

   n_p := Instr(prm_source,prm_separator,1,1);
   n_i := Length(prm_separator);

   If n_p = 0 Then
      Result := prm_source;
      prm_source := '';
   Else
      Result := substr(prm_source,1,n_p - 1);
      prm_source := Substr(prm_source,n_p+n_i);
   End If;

   return(Result);
end fun_gy_gettoken;
/
